package com.ajieee.merge.runner;

import com.ajieee.merge.mapper.TradeDateMapper;
import com.ajieee.merge.runner.finance.AbstractEtl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;

/**
 * @author ajieee
 * @date 2025-10-26
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class FinanceCommandLineRunner implements CommandLineRunner {

	private final List<AbstractEtl> list;

	private final TradeDateMapper tradeDateMapper;

	@Override
	public void run(String... args) {
		LocalDate tradeDate = tradeDateMapper.getTradeDate();
		for (AbstractEtl etl : list) {
			if (etl.needExecute(tradeDate)) {
				etl.execute();
			}
		}

		log.info("数据更新完成");
	}

}
